<script>
import request from "../utils/Request.js";
import {ElMessage} from "element-plus";

export default {
  methods: {
    oauth2Login(regId) {
      console.log(regId)
      request({
        method: 'get',
        url: '/api/uaa/oauth2/authorization/' + regId,
      })
          .then(resp => {
            let data = resp.data;
            console.log(resp)
            if (data.code === 0) {
              window.location.href = data.data
            } else {
              ElMessage.error("未知错误请重试")
            }
          })
          .catch(err => {
            ElMessage.error("未知错误请重试")
          })
    }
  }
}
</script>

<template>
  <div class=" w-300 text-center">
    <a class="mr-30" @click="oauth2Login('github')">
      <el-tooltip content="Github 登录" effect="dark" placement="bottom-end">
        <el-image class="img-style" src="/logo_github.svg" fit="fill"/>
      </el-tooltip>
    </a>
    <a @click="oauth2Login('gitee')">
      <el-tooltip content="Gitee 登录" effect="dark" placement="bottom-start">
        <el-image class="img-style" src="/logo_gitee.svg" fit="fill"/>
      </el-tooltip>
    </a>
  </div>
</template>

<style scoped>

.img-style {
  width: 40px;
  height: 40px;
  cursor: pointer;
}
</style>